//
//  ReadBaseModel.m
//  Otaku
//
//  Created by lanou3g on 16/5/16.
//  Copyright © 2016年 Liuwx. All rights reserved.
//

#import "ReadBaseModel.h"
#import "TextModel.h"
#import "ImageModel.h"
#import "MullImageModel.h"
@implementation ReadBaseModel



+ (instancetype) modelWithDictionary:(NSDictionary *)dictionary{
 
    
    if (dictionary[@"group"][@"text"] && dictionary[@"group"][@"large_image"][@"url_list"][0][@"url"]) {
        MullImageModel *mullModel = [MullImageModel new];
        [mullModel setValuesForKeysWithDictionary:dictionary];
        return mullModel;
    }
    if (dictionary[@"group"][@"text"] && !dictionary[@"group"][@"large_image"][@"url_list"][0][@"url"]) {
        TextModel *textModel = [TextModel new];
        [textModel setValuesForKeysWithDictionary:dictionary];
        return textModel;
    }
    if (!dictionary[@"group"][@"text"] && dictionary[@"group"][@"large_image"][@"url_list"][0][@"url"]) {
        ImageModel *imageModel = [ImageModel new];
        [imageModel setValuesForKeysWithDictionary:dictionary];
        return imageModel;
    }
    
    
    return nil;
}

- (void) setValue:(id)value forUndefinedKey:(NSString *)key {
    
}

- (void)setValue:(id)value forKey:(NSString *)key {
    [super setValue:value forKey:key];
    if ([key isEqualToString:@"group"]) {
        [self setValuesForKeysWithDictionary:value];
    }
    if ([key isEqualToString:@"id"]) {
        self.ID = value;
    }
    
    
    
}

@end
